Skip to content

feat(types): add FormSubmitHelpers and FormSubmitHandler typed exports - #17

Merged
javipuche merged 2 commits into
mainfrom
feat/typed-submit-handler
Mar 11, 2026
Merged

javipuche merged 2 commits into
mainfrom
feat/typed-submit-handler

Conversation

@javipuche

Copy link
Copy Markdown
Member

Summary

  • Replaces (...args: unknown[]) => void on setErrors with the precise SetErrorsInput = string | string[] | Record<string, string | string[]> union type
  • Exports new FormSubmitHelpers type (typed setErrors + reset)
  • Exports new generic FormSubmitHandler<T> so consumers can fully type their submit callbacks
  • Updates FormContext.setErrors, Form.vue emit, and test fixtures to use the new types

Usage

import type { FormSubmitHandler } from '@overgaming/valiform';

interface SignInValues {
  email: string;
  password: string;
}

const onSubmit: FormSubmitHandler<SignInValues> = async (values, { setErrors }) => {
  // values.email → string ✓
  // values.password → string ✓
};

Test plan

  • vue-tsc --noEmit passes (enforced by pre-commit hook)
  • Existing tests continue to pass

🤖 Generated with Claude Code

javipuche and others added 2 commits March 10, 2026 11:40
Replaces the loose `(...args: unknown[]) => void` signature on `setErrors`
with a precise `SetErrorsInput` union type. Exports `FormSubmitHelpers` and
the generic `FormSubmitHandler<T>` so consumers can fully type their submit
callbacks without casting.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@javipuche
javipuche merged commit 58987d0 into main Mar 11, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant